CheckTest <- function()
{
  Mang <-read.csv(file.choose(), header=TRUE)
  soCot=nrow(Mang)     

  for(i in 1:soCot)
  {
    MauTin <- Mang[i,1]
    array <-strsplit(as.character(MauTin),"")[[1]]
    Pr_A <- Mang[i,2]
    Pr_B <- Mang[i,3]
    Pr_Ac <-Mang[i,4]
    for(j in 1:length(array))
    {
      if(array[j]=="+")
      {
        Pr_A <-(Pr_A*Pr_B)/(Pr_A*Pr_B +(1-Pr_A)*Pr_Ac)
      }
      else if(array[j]=="-")
      {
        Pr_A <-(Pr_A*(1-Pr_B))/(Pr_A*(1-Pr_B)+(1-Pr_A)*(1-Pr_Ac))
      }
    }
    setwd("d:/")
    write(as.numeric(Pr_A),file="output_2.txt",append=TRUE)
    print(as.numeric(Pr_A))
  }
}

CheckTest()
